package com.qcby.model.resp;

import com.qcby.Constants;

import lombok.*;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class RespEntity<T> {

    private String code;

    private String msg;

    private T data;

    public static <T> RespEntity<T> successNoData(String msg) {
        return new RespEntity<T>(Constants.FLAG_200, msg, null);
    }

    //返回实体
    public static <T> RespEntity<T> successHaveData(T data) {
        return new RespEntity<>(Constants.FLAG_200, "成功！", data);
    }

    public static <T> RespEntity<T> successCustomize(String code, String msg, T data) {
        return new RespEntity<>(code, msg, data);
    }

    public static <T> RespEntity<T> errorNoData(String code, String msg) {
        return new RespEntity<>(code, msg, null);
    }

    public static <T> RespEntity<T> errorCustomize(String code, String msg, T data) {
        return new RespEntity<>(code, msg, data);
    }

    public static <T> RespEntity<T> errorSystem() {
        return new RespEntity<>(Constants.FLAG_500, "系统错误！", null);
    }
}
